{{#extend "header"}}
<title>支付结果</title>
<meta name="keywords" content="">
<meta name="description" content="">
{{/extend}}
{{#extend "style"}}
<style>
  body{
    background-color: white;
  }
  .ui-pay{
    text-align: center;
    font-size: 0.64rem;
    padding-top: 1rem;
    display: none;
  }
  .ui-pay-fail{
    color: #f04646;
  }
  .ui-pay-succ{
    color: #46c364;
  }
</style>
{{/extend}}
<body style="height: auto;">
  {{>nav title="支付结果" class="ui-shadow"}}
  <dl class="ui-pay ui-pay-fail">
    <dt>很抱歉，订单支付失败</dt>
    <dd><img src="/images/pay_fail.jpg"></dd>
  </dl>
  
  <dl class="ui-pay ui-pay-succ">
    <dt>恭喜您，订单支付成功</dt>
    <dd><img src="/images/pay_succ.jpg"></dd>
  </dl>
  
  
</body>

{{#extend "script"}}
<script type="text/babel">
  require.config({baseUrl: '/js/lib',urlArgs: "v0.0.3"});
  require(['zepto', 'lib'], function($, lib) {
    lib = new lib();
    var status = lib.getUrlParam('status'), orderId = lib.getUrlParam('oId');
    $(".ui-pay").show();
    if(status === "success"){
      $("body").append(`<a href="/order/order_list.html?ot=2" class="ui-red-botton" style="margin: 0 auto;width: 13.8rem;">查看订单</a>`);
      $(".ui-pay-fail").remove();
    }else{
      $("body").append(`<div class="ui-red-botton" style="margin: 0 auto;width: 13.8rem;">继续支付</div>`);
      $(".ui-pay-succ").remove();
      
      $(".ui-red-botton").tap(function(){
        if(lib.checkWeiXin()){
          if(lib.getIsOnline()){
            location.href = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' + lib.getReq().appid + 
            '&redirect_uri=http://api.chengshijiugui.com/csjgmanager/pay/wxPay.action&response_type=code&scope=snsapi_base&state='+ lib.getUrlParam('oId') + '#wechat_redirect';
          }else{
            location.href = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' + lib.getReq().appid + 
            '&redirect_uri=http://api.chengshijiugui.com/csjgmanager/pay/wxPay.action&response_type=code&scope=snsapi_base&state='+ lib.getUrlParam('oId') + '#wechat_redirect';
          }
        }else{
          lib.ajx(lib.getReq().ser + '/pay/alipay.action', {orderId: orderId, originType: 1}, function(data){
            if(data.infocode === "0"){
              location.href = data.info;
            }else{
              lib.showMessage(data.info);
            }
          }, function(){
            lib.showMessage('网络错误,请稍后再试');
          });
        }
      });
    }
  });
</script>
{{/extend}}
